#include <bits/stdc++.h>

#ifdef LLT_DBG
#define FR freopen("in.txt", "r", stdin)
#else
#define FR
#endif

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;
const ll inv2 = 500000004;

ll fpow(ll a, ll b)
{
    ll ans = 1;
    for (; b; b >>= 1, a = (a * a) % mod)
        if (b & 1)
            ans = (ans * a) % mod;
    return ans;
}

unordered_map<ll, ll> record;
const int MX = 5000000;
ll hcahce[MX];
bool isNPrime[MX];
ll primes[MX];
int tot;

void init()
{
    hcahce[1] = 1;
    for (ll i = 2; i < MX; i++)
    {
        if (!isNPrime[i])
        {
            hcahce[i] = i - 1;
            primes[tot++] = i;
        }

        for (int j = 0; j < tot && i * primes[j] < MX; j++)
        {
            isNPrime[i * primes[j]] = true;
            if (i % primes[j] == 0)
            {
                hcahce[i * primes[j]] = primes[j] * hcahce[i] % mod;
                break;
            }
            else
            {
                hcahce[i * primes[j]] = hcahce[i] * (primes[j] - 1) % mod;
            }
        }
    }

    for (int i = 1; i < MX; i++)
        hcahce[i] = (hcahce[i] + hcahce[i - 1]) % mod;
}

// 杜教筛
// g(1)S(n) = \sum_{i=1}^n f*g(i) - \sum_{i=2}^n g(i)S(n // i)

// 狄利克雷卷积经典公式
// phi * 1 = Id
// mu * 1 = eps
// phi = Id * mu

ll dfs(ll n)
{
    if (n < MX)
        return hcahce[n];

    if (record.count(n))
        return record[n];

    ll ans = n % mod * (n + 1) % mod * inv2 % mod;

    for (ll l = 2, r = 0; l <= n; l = r + 1)
    {
        r = n / (n / l);
        ans = (ans - (r - l + 1) % mod * dfs(n / l) % mod) % mod;
    }

    record[n] = ans;

    return ans;
}

void solve()
{
    init();
    ll n;
    cin >> n;
    cout << (dfs(n) + mod) % mod << endl;
}

int main()
{
    FR;
    solve();
    return 0;
}